﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EnglishLibrary;
using DataAccess;

namespace DataTransfer
{
    /// <summary>
    /// Transfer the data from the dataaccess object to the UI and vice versa
    /// </summary>
    public class NoteDT
    {
        //The object for invoking methods
        private NoteDAO noteDAO;

        public NoteDT()
        {
            noteDAO = new NoteDAO();
        }

        public NoteDT(string filePath)
        {
            noteDAO = new NoteDAO(filePath);
        }

        /// <summary>
        /// Get all the Notes in the database
        /// </summary>
        /// <returns>List of Notes</returns>
        public List<Note> GetListNote(bool isGetDeleted)
        {
            return noteDAO.GetListItems(isGetDeleted);
        }

        /// <summary>
        /// Insert a new Note into the database
        /// </summary>
        /// <param name="NoteItem">the Note item to insert</param>
        /// <returns>true if success or false if failure</returns>
        public bool InsertNote(Note noteItem)
        {
            return noteDAO.InsertItem(noteItem);
        }

        /// <summary>
        /// Update a Note
        /// </summary>
        /// <param name="NoteItem">the object which holds the infor</param>
        /// <returns>true if success, false if failure</returns>
        public bool UpdateNote(Note noteItem)
        {
            return noteDAO.UpdateItem(noteItem);
        }

        /// <summary>
        /// Get the items created before date
        /// </summary>
        /// <param name="date">the date to compare</param>
        /// <returns>results</returns>
        public List<Note> GetItemsBeforeDate(DateTime date)
        {
            return noteDAO.GetItemsBeforeDate(date);
        }

        /// <summary>
        /// Get the items created after date
        /// </summary>
        /// <param name="date">the date to compare</param>
        /// <returns>results</returns>
        public List<Note> GetItemsAfterDate(DateTime date)
        {
            return noteDAO.GetItemsAfterDate(date);
        }

        /// <summary>
        /// Get the items by catesID
        /// </summary>
        /// <param name="catesID">the cateID</param>
        /// <returns>the list</returns>
        public List<Note> GetItemsByCates(List<int> catesID)
        {
            return noteDAO.GetItemsByCates(catesID);
        }

        /// <summary>
        /// Get the items by id
        /// </summary>
        /// <param name="id">the id of this item</param>
        /// <returns>the item</returns>
        public Note GetItemByID(int id)
        {
            return noteDAO.GetItemByID(id);
        }

        /// <summary>
        /// Delete a Note
        /// </summary>
        /// <param name="noteId">the id of the note deleted</param>
        /// <returns>true if success, false if failure</returns>
        public bool DeleteNote(int noteId)
        {
            return noteDAO.DeleteItem(noteId);
        }

        public string FilePath
        {
            get { return noteDAO.FilePath; }
            set { noteDAO.FilePath = value; }
        }
    }
}
